/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/


#ifndef __PACT_TRANSLATOR_HDR__
#define __PACT_TRANSLATOR_HDR__


#include <stdexcept>


namespace pact{


	/*!
	 * \struct pact::translator_error
	 */
	struct translator_error : public std::runtime_error{
		translator_error(const std::string& msg) 
			:std::runtime_error(msg){}
	};


	/*!
	 * \class pact::Translator
	 */
	class Translator
	{
	public:

		enum VALUE_TYPE{ XYVALUE, ZVALUE, DZVALUE, VVALUE, DVVALUE, SVALUE };

		virtual ~Translator(){};
		virtual double operator()(double val, VALUE_TYPE unit = XYVALUE)const = 0;

	};	


	/*!
	 *  \class pact::MetricTranslator
	 */
	class MetricTranslator : public Translator
	{
	public:
		
		MetricTranslator(){};
		virtual ~MetricTranslator(){};

	public:

		virtual double operator()(double val, VALUE_TYPE unit)const{
			return val;
		}

	};


	/*!
	 * \class pact::SimpleAeroNauticTranslator
	 */
	class SimpleAeroNauticTranslator : public Translator
	{
	public:
		
		SimpleAeroNauticTranslator(){};
		virtual ~SimpleAeroNauticTranslator(){};

	public:

		virtual double operator()(double val, VALUE_TYPE unit)const;

	};



	/*!
	 * \class pact::AeroNauticTranslator
	 */
	class AeroNauticTranslator : public Translator
	{
	public:

		AeroNauticTranslator(){};
		virtual ~AeroNauticTranslator(){};

	public:

		virtual double operator()(double, VALUE_TYPE unit)const;

	private:

		double translate_xy(double)const;
		double translate_z(double)const;
		double translate_v(double)const;
		double translate_s(double)const;

	};

	
};

#endif
